namespace nu.Model
{
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;

    public class Package
    {
        private readonly string _name;
        private IPackageState _state;
        private List<PackageItem> _packageItems = new List<PackageItem>();
        private string _hash = null;

        public Package(string name)
        {
            this._name = name;
            this._state = new DraftPackageState(this);
        }

        public string Name
        {
            get { return this._name; }
        }

        public IPackageState State
        {
            get { return _state; }
        }

        public ReadOnlyCollection<PackageItem> Items
        {
            get { return new ReadOnlyCollection<PackageItem>(_packageItems); }
        }

        public string Hash
        {
            get { return _state.Hash; }
        }

        public PackageItem AddFileItem(string filePath)
        {
            return _state.AddFileItem(filePath, _packageItems);
        }

        public void Publish()
        {
            if (_state is DraftPackageState) _state = new PublishedPackageState(this);
        }

        public void AddReference(Package package)
        {
            throw new NotImplementedException();
        }
    }
}